/*
 * SPDX-FileCopyrightText: 2022-2023 liulinsong <liulinsong@kylinos.cn>
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 *
 */

#include "tabletmodewatcherstrategy.h"

namespace fcitx {

TabletModeWatcherStrategy::TabletModeWatcherStrategy(
    SubjectAvailabilityChangedCallback availabilityChangedCallback)
    : Strategy("TabletModeWatcherStrategy", "mode_change_signal",
               "get_current_tabletmode",
               std::move(availabilityChangedCallback)) {}

TabletModeWatcherStrategy::~TabletModeWatcherStrategy() = default;

bool TabletModeWatcherStrategy::isSubjectDefaultAvailable() const {
    return true;
}

bool TabletModeWatcherStrategy::isSubjectAvailableFromMethodMessage(
    dbus::Message &message) const {
    bool isTabletModeAvailable = isSubjectDefaultAvailable();

    auto reply = message.call(0);
    reply >> isTabletModeAvailable;

    return isTabletModeAvailable;
}

} // namespace fcitx